package com.wyz.utils.dingtalk.controller;

import com.wyz.utils.dingtalk.entity.Salesman;
import com.wyz.utils.dingtalk.req.ApprovalTemplateTableRes;
import com.wyz.utils.dingtalk.utils.DingTalkAnalyzeUtils;
import com.wyz.utils.dingtalk.entity.ProcessInstance;
import com.wyz.utils.dingtalk.entity.StoreProcessInstance;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class IndexController {

    @GetMapping
    public String index(){
        return "success";
    }


    @PostMapping
    public void test(@RequestBody List<ApprovalTemplateTableRes> resList) throws IllegalAccessException, InstantiationException {
        ProcessInstance process = DingTalkAnalyzeUtils.process(resList, ProcessInstance.class);
        log.info("process:{}",process);
    }

    @PostMapping("/store")
    public void test2(@RequestBody List<ApprovalTemplateTableRes> resList) throws IllegalAccessException, InstantiationException {
        StoreProcessInstance instance = DingTalkAnalyzeUtils.process(resList, StoreProcessInstance.class);
        log.info("instance:{}",instance);
    }

    @PostMapping("/employee")
    public void employee(@RequestBody List<ApprovalTemplateTableRes> resList) throws IllegalAccessException, InstantiationException {
        Salesman instance = DingTalkAnalyzeUtils.process(resList, Salesman.class);
        log.info("instance:{}",instance);
    }
}
